package com.wn.base;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;

import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;

/**
 * @FileName: MethodMappingEnum
 * @Description: TODO
 * @Author: MaWenHao
 * @Created: 2021/2/1 - 12:29
 * @Version: V1.0
 * @Company: 东方微银科技（北京）有限公司
 */
@AllArgsConstructor
public enum MethodMappingEnum {
    HIGH("高", "setHigher")
    ;
    @Getter
    @Setter
    private String code;

    @Getter
    @Setter
    private String methodName;

    private static final MethodMappingEnum[] values = MethodMappingEnum.values();

    public static String findMethodName(String code) {
        Optional<MethodMappingEnum> optional = Arrays.stream(values).filter(e -> Objects.equals(code, e.getCode())).findFirst();
        if (optional.isPresent()) {
            return optional.get().getMethodName();
        }
        return null;
    }
}
